package training;

import java.util.Scanner;
// https://www.nowcoder.com/questionTerminal/d95d98a2f96e49078cd7df84ba0c9d79
public class Day31_01 {
    // 判断是否是闰年
    public static boolean isRYear(int y) {
        return (y % 400 == 0) || (y % 4 == 0 && y % 100 != 0);
    }

    private static final int[] arr = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    // 给定年月日，返回是改年的第多少天
    private static int tDays(int y, int m, int d) {
        int num = d;
        for (int i = 0; i < m - 1; i++) {
            num += arr[i];
        }
        if (m > 2 && isRYear(y)) {
            num++;
        }
        return num;
    }

    // 根据年月日，找到从公元1年12月31日星期日开始过了多久 求出他的同余数
    private static int whatLong(int y, int m, int d) {
        return (y - 1) + (y - 1) / 4 - (y - 1) / 100 + (y - 1) / 400 + tDays(y, m, d);
    }

    // 根据年月日，求出星期几
    private static int whatWeek(int y, int m, int d) {
        int w = whatLong(y, m, d) % 7;
        return w == 0 ? 7 : w;
    }

    // 根据1日星期w，求第n个星期e是几号
    private static int theNWeekE(int w, int n, int e) {
        return 1 + (n - 1) * 7 + (7 - w + e) % 7;
    }

    // 根据6月1日星期w，求5月的最后一个星期1
    private static int mayLastWeek1(int w) {
        return 32 - (w == 1 ? 7 : w - 1);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int y = scanner.nextInt();
            int w;
            System.out.printf("%d-01-01\n", y);

            w = whatWeek(y, 1, 1);
            System.out.printf("%d-01-%02d\n", y, theNWeekE(w, 3, 1));

            w = whatWeek(y, 2, 1);
            System.out.printf("%d-02-%02d\n", y, theNWeekE(w, 3, 1));

            w = whatWeek(y, 6, 1);
            System.out.printf("%d-05-%02d\n", y, mayLastWeek1(w));

            System.out.printf("%d-07-04\n", y);

            w = whatWeek(y, 9, 1);
            System.out.printf("%d-09-%02d\n", y, theNWeekE(w, 1, 1));

            w = whatWeek(y, 11, 1);
            System.out.printf("%d-11-%02d\n", y, theNWeekE(w, 4, 4));

            System.out.printf("%d-12-25\n", y);
            System.out.println();
        }
    }
}
